﻿namespace LeetCodeProject._0001_1000._001_100._51_60._058;

public class Solution
{
    public int LengthOfLastWord(string s)
    {
        var i = s.Length - 1;
        while (i >= 0 && s[i] == ' ')
            i--;
        var start = i;
        while (start >= 0 && s[start] != ' ')
            start--;
        return i - start;
    }
}